package client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class TratadorDeString {

    private static PrintStream saida;
    private static BufferedReader entrada;
    private static String  stringRecebida;
   

    public TratadorDeString(Socket socket) throws IOException{
        saida = new PrintStream(socket.getOutputStream());


    }


    public static void enviaString(String string){
        saida.println(string);

    }

    public static String recebeString(Socket socket) throws IOException{
         entrada = new BufferedReader(new InputStreamReader(socket.getInputStream()));
         while (true){
             stringRecebida = entrada.readLine();

             if (stringRecebida == null){
                 System.out.println("conexão encerrada!");
                 System.exit(0);
             }
             System.out.println();
             System.out.println(stringRecebida);
             System.out.print(" Responder > ");

         }

    }


}
